package com.huangliusong.demo2;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTest2 {

    public  void test(){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        Bean1 b=(Bean1)applicationContext.getBean("bean1");
        b.save();
        ((ClassPathXmlApplicationContext) applicationContext).close();
    }

    @Test
    public  void test2(){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        Bean2 bean2=(Bean2)applicationContext.getBean("bean2");
        Bean2 bean22=(Bean2)applicationContext.getBean("bean2");
        System.out.println(bean2==bean22);
    }
}
